import axios from 'axios';
import util from '../utils/util'


export function getAssessmentTemplateList() {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    return axios.get("/erm/template/getTemplateList?v=v1.0" + "&t=" + new Date().getTime(), headerOptions).then(response => response).catch(errot => error);
}

export function addAssessmentTemplate(template) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    var json = { 'template': template};
    return axios.post("/erm/template/createTemplate?v=v1.0", json, headerOptions).then(response => response).catch(errot => error);
}

export function deleteAssessmentTemplate(templateId) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    // var json = { 'templateId': templateId};
    return axios.delete("/erm/template/delTemplate/?v=v1.0&templateId=" + templateId, headerOptions).then(response => response).catch(errot => error);
}

export function getAssessmentList(params) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    return axios.get("/erm/evaluate/listEvaluate?v=v1.0" + params + "&t=" + new Date().getTime(), headerOptions).then(response => response).catch(errot => error);
}

export function addAssessmentTask(param) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    return axios.post("/erm/evaluate/createEvaluate?v=v1.0", param, headerOptions).then(response => response).catch(errot => error);
}

export function editAssessmentTask(param) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    return axios.post("/erm/evaluate/updateTaskEvaluate?v=v1.0", param, headerOptions).then(response => response).catch(errot => error);
}

export function getAssessmentTaskDetail(evaluateId) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    return axios.get("/erm/evaluate/taskDetailsEvaluate?v=v1.0&evaluateId=" + evaluateId + "&t=" + new Date().getTime(), headerOptions).then(response => response).catch(errot => error);
}

export function getAssessmentProgress(eid) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    var json = { 'evaluateId': eid};
    return axios.get("/erm/evaluate/taskScheduleEvaluate?v=v1.0&evaluateId="+eid + "&t=" + new Date().getTime(), headerOptions).then(response => response).catch(errot => error);
}
export function getAssessmentDetail(eid) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    var json = { 'evaluateId': eid};
    return axios.get("/erm/evaluate/taskDetailsEvaluate?v=v1.0&evaluateId="+eid + "&t=" + new Date().getTime(), headerOptions).then(response => response).catch(errot => error);
}
export function getAssessmentReport(entityId, eid, evaluateStartTime) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    var params = 'evaluateId='+eid+'&entityId='+entityId+'&evaluateStartTime='+evaluateStartTime
    return axios.get("/erm/evaluate/selectReportEvaluate?v=v1.0&"+params + "&t=" + new Date().getTime(), headerOptions).then(response => response).catch(errot => error);
}
export function getTemplateDetails(templateId) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    return axios.get("/erm/template/getTemplateDetails?v=v1.0&templateId="+templateId + "&t=" + new Date().getTime(), headerOptions).then(response => response).catch(errot => error);
}
export function updateTemplate(template) {
    const headerOptions = {
        headers: {
            "Content-Type": "application/json"
        }
    };
    var json = { 'template': template};
    return axios.post("/erm/template/updateTemplate?v=v1.0",json , headerOptions).then(response => response).catch(errot => error);
}